
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>方法重载参数类型自动转换 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>方法重载参数类型自动转换 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Java方法重载中，进行形参匹配时的首要规则是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">首要规则是先匹配与实参类型完全一致的形参。例如，对于调用 `b(1)`，由于 `1` 默认是 `int` 类型，会优先匹配形参为 `int` 的方法。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如果在方法重载中找不到与实参类型完全匹配的形参，接下来的匹配策略是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">如果没有找到类型完全匹配的参数，匹配机制会尝试向字节数更大的兼容基本数据类型进行匹配，即所谓的“类型提升”。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当无法通过类型提升找到匹配的基本数据类型时，Java的重载匹配机制会如何继续？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">如果更大的基本数据类型也没有匹配的参数，匹配机制会接着寻找对应的包装类型（Boxing）。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Java方法重载的形参匹配中，最后的“兜底”匹配类型是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">如果连包装类也无法匹配到，最终会寻找并匹配到 `Object` 类型的形参。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">请根据文档，总结Java方法重载中形参匹配的完整优先级顺序。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">形参匹配的优先级顺序如下：<br>1. 匹配完全相同的类型。<br>2. 匹配字节数更大的基本数据类型（类型提升）。<br>3. 匹配对应的包装类型。<br>4. 匹配 Object 类型。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">根据文档提供的代码示例和匹配规则，调用 `b(1)` 会执行哪个具体的重载方法？请解释原因。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">会执行 `public static void b(int b)` 方法。原因是，调用时传入的参数 `1` 默认是 `int` 类型，根据首要匹配规则“先匹配和自己的类型一致的形参”，它会直接匹配到形参为 `int` 的版本。</div>
          </div>
          <div class="card-source">来源: 在方法重载的情况下形参是如何匹配的</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
